<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <script language="javascript" type="text/javascript" src="${ctx}/static/datepicker/WdatePicker.js"></script>
   <script type="text/javascript">
	     function exportExcel(){
	     var beginTimeStr = $("#beginTimeStr").val();
		if (beginTimeStr == "" || beginTimeStr == null) {
			$("#beginTimeStr").focus();
			$("#timeMessage").html("起始时间不能为空");
			$("#timeMessage").show();
			return;
		}
		var endTimeStr = $("#endTimeStr").val();
		if (endTimeStr == "" || endTimeStr == null) {
			$("#endTimeStr").focus();
			$("#timeMessage").html("终止时间不能为空");
			$("#timeMessage").show();
			return;
		}
	        $("#queryForm").attr("action","${ctx}/exportBackupTask/exportExcel");
	        $("#queryForm").submit();
	        return false;
	     }
	     
	  function ajaxAreaGroup(item) {
		$.ajax({
					type : 'post',
					url : '${ctx}/v2/customers/ajaxAreaGroup',
					data : 'customerCode=' + item.value,
					dataType : 'json',
					success : function(data) {
					  var tempString="";
						if (data.status == "1") {
							$.each(data.content.restAreaGroupDtos,function(i){
							    tempString+="<option value="+data.content.restAreaGroupDtos[i].areagroupCode+">"+data.content.restAreaGroupDtos[i].areagroupName;
							});
						} else {
							alert(data.content);
						}
                        $("#areaLists").html(tempString);
                        $("#areaLists").trigger("chosen:updated");
					},
					error : function() {
						alert("获取信息错误！");
					}
				});
	}
	
	function query() {
		var beginTimeStr = $("#beginTimeStr").val();
		if (beginTimeStr == "" || beginTimeStr == null) {
			$("#beginTimeStr").focus();
			$("#timeMessage").html("起始时间不能为空");
			$("#timeMessage").show();
			return;
		}
		var endTimeStr = $("#endTimeStr").val();
		if (endTimeStr == "" || endTimeStr == null) {
			$("#endTimeStr").focus();
			$("#timeMessage").html("终止时间不能为空");
			$("#timeMessage").show();
			return;
		}
		$("#inputForm").attr("action", "${ctx }/exportBackupTask/pageBackupTask");
		$("#inputForm").submit();
	}
	</script>
  </head>
  
  <body>
  	<div>
    	<div id="timeMessage" class="alert alert-success" style="display: none;"></div>
  	</div>
							 
   <div class="span15" style="margin-left: 20px;">
       <form method="post" id="inputForm" class="form-search">
      
						<label>
							<b>客户:</b>
						</label>
						<select name="search_EQ_customerCode" class="input-medium" style="width: 220px;" onchange="ajaxAreaGroup(this)" id="customerId">
							<c:forEach items="${customers}" var="obj">
								<option value="${obj.customerCode}"
									<c:if test="${param.search_EQ_customerCode eq obj.customerCode}">selected</c:if>>
									${obj.customerName}
								</option>
							</c:forEach>
						</select>
						<label>
							<b>网点:</b>
						</label>
						<select name="search_EQ_areaGroupCode" class="input-medium" style="width: 220px;" id="areaLists">
							<c:forEach items="${object.restAreaGroupDtos}" var="obj">
								<option value="${obj.areagroupCode}"
									<c:if test="${param.search_EQ_areaGroupCode eq obj.areagroupCode}">selected</c:if>>
									${obj.areagroupName}
								</option>
							</c:forEach>
						</select>
						<label>
							<b>开始时间:</b>
						</label>
						<input type="text" id="beginTimeStr" name="search_EQ_fromDate"
							value="${param.search_EQ_fromDate }"
							onFocus="WdatePicker({maxDate:'#F{$dp.$D(\'endTimeStr\')}',startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:false,readOnly:true})" />
					
						<label>
							<b>结束时间:</b>
						</label>
						<input type="text" id="endTimeStr" name="search_EQ_endDate"
							value="${param.search_EQ_endDate }"
							onFocus="WdatePicker({minDate:'#F{$dp.$D(\'beginTimeStr\')}',startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:false,readOnly:true})" />
					
						<button type="button" onclick="query();" class="btn">
							查询
						</button>
					
						<a class="btn btn-primary"  href="#" onclick="exportExcel();">导出报表</a>
					
   </form>
   					</div>
   
   <form class="form-search" id="queryForm" method="post">
	 	<input type="hidden" id="_customerCode" name="search_customerCode" value="${param.search_EQ_customerCode}"/>
	 	<input type="hidden" id="_fromDate" name="search_fromDate" value="${param.search_EQ_fromDate}"/>
	 	<input type="hidden" id="_endDate" name="search_endDate" value="${param.search_EQ_endDate}"/>
	 	<input type="hidden" id="_areaGroupCode" name="search_areaGroupCode" value="${param.search_EQ_areaGroupCode}"/>
    </form>
    <table id="contentTable"
			class="table table-striped table-bordered table-condensed">
			<thead>
				<tr>
					<th>
						编号
					</th>
					<th>
						时间
					</th>
					<th>
						订单数量
					</th>
					<th>
						商品数量
					</th>
					<th>
						商品种类
					</th>
					<th>
						类别
					</th>
					<th>
						批次类型
					</th>
					<th>
						操作人
					</th>
					<th>
						状态
					</th>
					<th>
						操作
					</th>
				</tr>
			</thead>
				<tbody>
					<c:forEach items="${pageBackupTasks.content}" var="obj">
						<tr>
							<td>
								${obj.backupTaskCode }
							</td>
							<td>
								${obj.createDate }
							</td>
							<td>
								<a href="${ctx }/backupTask/showOrdenos/${obj.backupTaskCode}">${obj.ordenoQty
									}</a>

							</td>
							<td>
								${obj.skuQty }
							</td>
							<td>
								${obj.skuType }
							</td>
							<td>
								<c:if test="${obj.type eq 'single' }">
							         单件
							</c:if>
								<c:if test="${obj.type eq 'multiple' }">
							            多件
							</c:if>
								<c:if test="${obj.type eq 'forward' }">
							  中转发
							</c:if>
							</td>
							<td>
								<c:if test="${obj.batchType eq 'zwarehouse'}">
									<span class="label label-success">总仓订单</span>
								</c:if>
								<c:if test="${obj.batchType eq 'fwarehouse'}">
									<span class="label label-important">分仓订单</span>
								</c:if>
							</td>
							<td>
								${obj.username }
							</td>
						
							<td>

								<c:choose>
									<c:when test="${obj.type eq 'forward' }">
										<span class="label label-success"> 打单</span>
									</c:when>
									<c:otherwise>
										<c:if test="${obj.pickStatus eq 'finish' }">
											<span class="label label-success"> 拣货完成</span>
										</c:if>
										<c:if test="${obj.pickStatus eq 'pending' }">
											<span class="label label-importment">未拣货</span>
										</c:if>
									</c:otherwise>
								</c:choose>

							</td>
							<td>
								<a class="btn"
									href="${ctx}/backupTask/exportExcel/${obj.backupTaskCode}">导出</a>
							</td>
						</tr>
					</c:forEach>
				</tbody>
			
		</table>
		
    <c:if test="${status eq '1' }">
    
		  <tags:pagination page="${pageBackupTasks}" paginationSize="5" />
	</c:if>
  </body>
</html>
